package com.servlet;
import java.io.IOException;

import com.javabean.Student;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@WebServlet("/delete")
public class DeleteServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			req.setCharacterEncoding("utf-8");
			resp.setContentType("text/html;charset=utf-8");
			//第1步: 获取参数
			String no = req.getParameter("no");
			//第2步:调用del方法
			Student.del(no);
			//第3步: 页面跳转回stu_list.jsp页面
			req.getRequestDispatcher("stu_list.jsp").forward(req, resp);
	}		
}
